function check_secure() {
var httpsRE = /^https/i;
if (!window.location.origin.match(httpsRE)) {
window.location = "https://" + window.location.hostname + window.location.pathname + window.location.search;
}
}
check_secure();